package com.itheima.demobyfinal;

//智能控制系统类,单例类
public class SmartHomeControl {
    private static final SmartHomeControl smartHomeControl = new SmartHomeControl();
    private SmartHomeControl(){}    //先把构造器私有
    public static SmartHomeControl getInstance(){
        return smartHomeControl;
    }

    public static void printAllStatus(JD[] jds) {
        for (int i = 0; i < jds.length; i++) {
            System.out.println((i+1)+":"+jds[i].getName() + "的状态目前是:" + (jds[i].isStatus() ? "开" : "关"));
        }
    }

    //多态
    public void control(JD jd) {
        //boolean是is不是get
        System.out.println(jd.getName() + "的状态目前是" + (jd.isStatus() ? "开" : "关"));
        System.out.println("开始您的操作");

        jd.press(); //按下开关
        System.out.println(jd.getName() + "的状态目前是" + (jd.isStatus() ? "开" : "关"));

    }
}
